<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
</title>
    <include file="Public:header" />
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerForm.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerDateEditor.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerRadio.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
   
    <script type="text/javascript">
        $(function ()
        {
         //  $("#form1").ligerForm();
          // var groupAppList=jQuery.parseJSON({$mgroupList}){ 
        	   var groupAppList={$mgroupList};
                SetChecked(groupAppList);
                $("#form1").ligerForm();
             
                var gm=$("#groupId").ligerGetComboBoxManager();
                gm.bind('Selected', function (value)
                        {
                           // alert(value);
                            location.href = '__URL__/app/groupId/'+value;

                        });
                //onSelected="location.href = '__URL__/app/groupId/'+this.options[this.selectedIndex].value;"
               // gm.ligerComboBox({onSelected: function (newvalue){alert('选择的是' + newvalue);}});

        
           function SetChecked(groupAppList){
        	   $("input[name='groupAppId[]']").each( function() {   
                   for (var item in groupAppList) {
//                	   alert(groupAppList[item]);
                	   if($(this).val()==groupAppList[item]){
                		  $(this).attr("checked", true);
                	  }
                	 }
               });   
           }
           
           $("#selectAll").click( function() {   
        	   $("input[name='groupAppId[]']").each( function() {   
                   $(this).attr("checked", true); 
                   $(this).ligerGetCheckBoxManager().setValue(true);
                 //  alert( $(this).attr("checked"));
               });   
           });   
           // 反选   
           $("#inverseAll").click( function() {   
               $('input[name="groupAppId[]"]').each( function() {   
                   $(this).attr("checked", !$(this).attr("checked"));
                  var cb=$(this).ligerGetCheckBoxManager();
                  alert(cb.getValue());
                  cb.setValue(!cb.getValue());
                  if(cb.getValue()=true){
                	  cb.setvalue(false);
                  }else{
                	  cb.setvalue(true);
                  }
               });   
           });   
         
           // 取消全部   
           $("#deselectAll").click( function() {   
               $("input[name='groupAppId[]']").each( function() {   
                   $(this).attr("checked", false);  
                   $(this).ligerGetCheckBoxManager().setValue(false);
               });   
           }); 
           $("#save").click( function() {   
             /*  var selectedStr = "";   
               var $send = $("input[name='groupAppId[]']");   
               $send.each( function() {   
                   if ($(this).attr("checked")) {   
                       selectedStr += $(this).val() + ",";   
                   }   
               });   
               if ($.trim(selectedStr) == "") {   
                   alert("请未选中任何数据!");   
                   return false;   
               }   
                     alert(selectedStr );*/   
              var sq=$("#form1").serialize();
               $.post("__URL__/setApp",$("#form1").serialize(),function(data){
                    alert(data);//
                  // 	$.ligerDialog.alert(data);
 			    });
           });   
               
        }); 
    </script>
    <style type="text/css">
        
        .l-table-edit {}
        .l-table-edit-td{ padding:4px;}
        .l-button-submit,.l-button-reset{width:50px; float:left; margin-left:10px; padding-bottom:2px;}
        .l-verify-tip{ left:230px; top:120px;}
    </style>

</head>

<body style="padding:10px">
<div></div>
<form name="form1" method="post" id="form1">
    <table cellpadding="0" cellspacing="0" class="l-table-edit" >
             <tr>
                <td align="right" class="l-table-edit-td" valign="top">当前组:</td>
                <td align="left" class="l-table-edit-td">
                        <select name="groupId" id="groupId" ltype="select"  >
                        	<foreach name="groupList" item="vo" key="gid">
                        	<if condition="$selectGroupId eq $gid">
                        		<option value={$gid} selected>{$vo}</option>
                        	<else/>
                        		<option value={$gid}>{$vo}</option>
                        	</if>
                        	</foreach>
  						</select>
                </td>
                <td align="left"></td>
            </tr> 
             <tr>
                <td align="right" class="l-table-edit-td" valign="top">应用:</td>
                <td align="left" class="l-table-edit-td">
                      	<foreach name="appList" item="vo" key="gid">
                       			<input id="cb_{$gid}" type="checkbox" name="groupAppId[]" value="{$gid}" ><label for="cb_{$gid}">{$vo}</label></br>
                      	</foreach>
                </td>
                <td align="left"></td>
            </tr>  
            <tr height="100"><td colspan="3"></td></tr>
            <tr>
            	<td align="center" colspan="3">
					<input type="button" class="l-button-submit" id="selectAll" name="selectAll" value="全选" />  
					<input type="button" class="l-button-submit" id="inverseAll" name="inverseAll" value="反选" />  
					<input type="button" class="l-button-submit" id="deselectAll" name="deselectAll" value="取消" />  
                 	<input type="button" class="l-button-submit" id="save" name="save" value="应用" />  
					<input type="hidden" name="module" value="Node">
            	</td>
            </tr> 

        </table>
      </form>
    <div style="display:none">
</body>
</html>
